//
//  BPUserInfo.swift
//  BPWeiBo
//
//  Created by 扒皮大叔 on 16/4/9.
//  Copyright © 2016年 apple. All rights reserved.
/*
 Optional({
 "allow_all_act_msg" = 0;
 "allow_all_comment" = 1;
 "avatar_hd" = "http://tva1.sinaimg.cn/crop.0.0.720.720.1024/005x6QSajw8ehs142pw44j30k00k0dhb.jpg";
 "avatar_large" = "http://tp3.sinaimg.cn/5069916462/180/5698771008/1";
 "bi_followers_count" = 14;
 "block_app" = 0;
 "block_word" = 0;
 city = 5;
 class = 1;
 "cover_image_phone" = "http://ww2.sinaimg.cn/crop.0.0.640.640.640/a1d3feabjw1ecat8op0e1j20hs0hswgu.jpg";
 "created_at" = "Thu Mar 13 23:48:50 +0800 2014";
 "credit_score" = 80;
 description = "\U4eb2\U7231\U7684\U5c0f\U5b69\U3002\U3002\U3002";
 domain = "";
 "favourites_count" = 6;
 "follow_me" = 0;
 "followers_count" = 51;
 following = 0;
 "friends_count" = 161;
 gender = m;
 "geo_enabled" = 1;
 id = 5069916462;
 idstr = 5069916462;
 lang = "zh-cn";
 location = "\U5317\U4eac \U671d\U9633\U533a";
 mbrank = 0;
 mbtype = 0;
 name = "\U76ae\U76ae\U4e0d\U4f11";
 "online_status" = 0;
 "pagefriends_count" = 1;
 "profile_image_url" = "http://tp3.sinaimg.cn/5069916462/50/5698771008/1";
 "profile_url" = "u/5069916462";
 province = 11;
 ptype = 0;
 remark = "";
 "screen_name" = "\U76ae\U76ae\U4e0d\U4f11";
 star = 0;
 status =     {
 annotations =         (
 {
 "mapi_request" = 1;
 }
 );
 "attitudes_count" = 0;
 "biz_feature" = 0;
 "comments_count" = 0;
 "created_at" = "Fri Apr 08 07:39:19 +0800 2016";
 "darwin_tags" =         (
 );
 favorited = 0;
 geo = "<null>";
 "hot_weibo_tags" =         (
 );
 id = 3961892986840913;
 idstr = 3961892986840913;
 "in_reply_to_screen_name" = "";
 "in_reply_to_status_id" = "";
 "in_reply_to_user_id" = "";
 isLongText = 0;
 mid = 3961892986840913;
 mlevel = 0;
 "pic_urls" =         (
 );
 "reposts_count" = 0;
 source = "<a href=\"http://app.weibo.com/t/feed/5B6hUc\" rel=\"nofollow\">iPhone 6s Plus</a>";
 "source_allowclick" = 0;
 "source_type" = 1;
 text = "//@iOS\U7a0b\U5e8f\U72ad\U8881:CocoaPods \U7248\U672c\U53f7\U66f4\U65b0\U81f3v1.2.4\Uff0c\U80fd\U6839\U636ePlusButton\U7684\U5bbd\U5ea6\U81ea\U52a8\U8c03\U6574TabBarItem\U7684\U5bbd\U5ea6\Uff0c\U76f8\U5173\U8bf4\U660e\U5982\U4e0b\Uff1a http://t.cn/Rqq88uB";
 "text_tag_tips" =         (
 );
 truncated = 0;
 userType = 0;
 visible =         {
 "list_id" = 0;
 type = 0;
 };
 };
 "statuses_count" = 743;
 urank = 14;
 url = "";
 "user_ability" = 0;
 verified = 0;
 "verified_reason" = "";
 "verified_reason_url" = "";
 "verified_source" = "";
 "verified_source_url" = "";
 "verified_trade" = "";
 "verified_type" = "-1";
 weihao = "";
 })
 */

import UIKit
//将需要保存的信息设置成属性,不需要保存的直接过滤掉就行
class BPUserInfo: NSObject {
    //用户授权的唯一票据
    var access_token: String?
    
    
    //access_token的生命周期,单位是秒数
    //10 + 当前的日期=>获取过期的期限
    //就是在我们每次使用的时候,就去判断是否过期
    //让过期日期和当前进行比较
    var expires_in: NSTimeInterval = 0 {
        didSet {
        expires_data = NSDate(timeIntervalSinceNow: expires_in)
        
        }
    }
    
    //添加过期的字段
    var expires_data:NSDate?
    
    //标示唯一的用户的id
    var uid: String?
    //用户显示的名称
    var name: String?
    //用户头像 180 * 180
    var avatar_large: String?
    
    //字典赚模型
    init(dict: [String : AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    
    }

    //过滤
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {
        
    }
    
    
    //MARK:将对象转化成字符串,获取字典,用来取值
    override var description: String {
        let keys = ["access_token","avatar_large","name","uid","expires_in","expires_data"]
        
        let dict = self.dictionaryWithValuesForKeys(keys)
        return dict.description
    }
    
}
